//
// Created by Administrator on 2023/7/29.
//
#include <iostream>

using namespace std;

struct ListNode {
    int val;
    ListNode *next;

    ListNode(int x) : val(x), next(nullptr) {}
};
class Solution {
public:
    void deleteNode(ListNode* node) {
        node->val = node->next->val;
        node->next = node->next->next;
        ListNode * tmp = node->next;
        delete node->next;
        *node = *node->next;
    }
    void printNode(ListNode *node){
        while (node != nullptr){
            cout << node->val <<endl;
            node = node->next;
        }
    }
};

int main(){
    ListNode n1{4},n2{5},n3{1},n4{9};
    n1.next = &n2;
    n2.next = &n3;
    n3.next = &n4;
    Solution s;
    s.deleteNode(&n3);
    s.printNode(&n1);
}